<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/19
 * Time: 15:03
 */
//$arr = [false,0,"",1,"a","false"];
$arr = range(1,10);
$brr = array_filter($arr);
var_dump($brr);

$brr = array_filter($arr,function($v){
    return $v;
});
var_dump($brr);

$brr = array_filter($arr,function($v){
    if ($v%2==0){
        return true;
    } else {
        return false;
    }
});
var_dump($brr);



function my_filter($arr,$callback){
    $tmp = [];
    foreach($arr as $k=>$v){
        if ($callback($v)){
            $tmp[$k]=$v;
        }
    }
    return $tmp;
}

$brr = my_filter($arr,function($v){
    if ($v%2==0){
        return true;
    } else {
        return false;
    }
});


var_dump($brr);